#include <iostream>
#include <cstdio>
#define int long long
#define file
using namespace std;
int n, a[100005], cnt, mx = -1, ans;
int t[100005], s[100005], h[100005];
signed main()
{
#ifdef file
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);
#endif
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if (a[i] > mx)
            mx = a[i];
        if (a[i] != 1 && a[i] != 2)
            cnt++;
    }
    if (!cnt)
    {
        int cnt1 = 0, cnt2 = 0;
        for (int i = 1; i <= n; i++)
        {
            if (a[i] == 1)
                cnt1++;
            else if (a[i] == 2)
                cnt2++;
        }
        if (cnt2 >= cnt1)
            cout << cnt2 << endl;
        else
            cout << cnt1 << endl;
    }
    else
    {
        int num = 0;
        for (int i = 1; i <= n; i++)
            t[a[i]]++;
        for (int i = 1; i <= mx; i++)
            if (t[i])
                s[++num] = i;
        for (int i = 1; i < num; i++)
        {
            while (t[s[i]] && h[s[i + 1]] < t[s[i + 1]])
            {
                t[s[i]]--;
                h[s[i + 1]]++;
            }
        }
        for (int i = 1; i <= mx; i++)
            ans += t[i];
        cout << ans << endl;
    }
    return 0;
}
